package cn.dglydrpy.study.j2ee.servlet.day09;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class CommentServlet
 */
public class CommentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static List<String> comments = new ArrayList<String>();
	

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("service()开始执行");
		request.setCharacterEncoding("utf-8");
		String content = request.getParameter("content");
	
		System.out.println("servlet"+comments);
		comments .add(content);
		
		request.setAttribute("comments", comments);
		System.out.println("service()执行完毕，即将跳转到jsp");
		request.getRequestDispatcher("comment.jsp").forward(request, response);
	}

}
